<root xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="rds.html" />

    <report>
        <?python
            from mnemoply.utils import date2str_points
            from mnemoply.common_knowledge import day_captions

            group = model.Group.get(ids[0])
            sigs = list(model.StudentInGroup.selectBy(group=group))
            sigs.sort(key = lambda x: x.student.fullName)

            lessons_in_schedule = model.LessonInSchedule.selectBy(group=group)
            lessons = group.getLessons()
            topics = model.GroupTopic.selectBy(group=group)
            teacher = group.teacher.title
            days = [day_captions[l.dayOfWeek].__unicode__() for l in lessons_in_schedule]
        ?>
        <group>
            <title py:content="group.cacheTitle" />
            <startdate py:content="date2str_points(group.startDate)" />
            <days py:content="', '.join(days)" />
            <totalhours py:content="sum([t.hours for t in topics])" />
            <hours py:content="sum([t.hours for t in topics])/len(lessons)" />
            <teahcer py:content="teacher" />
        </group>
        <sig py:for="n, sig in enumerate(sigs)">
            <num py:content="n+1" />
            <name py:content="sig.student.fullName" />
        </sig>
    </report>

</root>
